import { IPSAppCodeList } from '../../app/codelist/ipsapp-code-list';
import { IPSDETreeCodeListNode } from './ipsdetree-code-list-node';
import { PSDETreeNodeImplBase } from './psdetree-node-impl-base';

export class PSDETreeCodeListNodeImpl extends PSDETreeNodeImplBase implements IPSDETreeCodeListNode {
  protected psappcodelist: IPSAppCodeList | null = null;

  getPSCodeList(): IPSAppCodeList | null {
    if (this.psappcodelist != null) return this.psappcodelist;
    const value = this.M.getPSCodeList;
    if (value == null) {
      return null;
    }
    this.psappcodelist = this.getPSModel4('app.codelist.IPSAppCodeList', value, 'getPSCodeList') as IPSAppCodeList;
    return this.psappcodelist;
  }

  get psCodeList(): IPSAppCodeList | null {
    return this.getPSCodeList();
  }

  getPSCodeListMust(): IPSAppCodeList {
    const value = this.getPSCodeList();
    if (value == null) {
      throw new Error('未指定应用代码表对象');
    }
    return value;
  }

  get appendCaption(): boolean {
    return this.M.appendCaption;
  }

  get cls(): string {
    return 'PSDETreeCodeListNodeImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.tree.IPSDETreeCodeListNode') return true;
    return super.instanceof(cls);
  }
}
